<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>函数传参改变div属性</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .content{
            width: 200px;
            margin: 0 auto;
        }
        .top{
            display: flex;
            flex-direction: column;
        }

       
        #bottom{
            width: 200px;
            height: 200px;
            background-color: black;
            color: white;
            font-size: 12px;
            box-sizing: border-box;
            padding: 10px;
        }

    </style>
</head>
<body>
    <div class="content">
    <div class="top">
        <label for="txt1">属性名：<input type="text" id="txt1" value="background"></label>
        <label for="txt2">属性值：<input type="text" id="txt2" value="pink"></label>
        <button onclick="determine()">确定</button>
        <button onclick="Reset()">重置</button>
    </div>
    <div  id="bottom"> 在上方输入框输入“属性名”及属性值，点击确定按钮查看效果 </div>
    <script>
        var txt1 = document.getElementById('txt1')
        var txt2 = document.getElementById('txt2')
        var bottom = document.getElementById('bottom')
        var divChange = function(d1,d2,d3){
            d1.style[d2] = d3
        }
        // function determine(){
        //     divChange(bottom, txt1.value, txt2.value)
        // }
        function determine(){
            var shu = txt1.value
            console.log(shu);
            console.log(txt2.value);
            bottom.style = `${txt1.value}:${txt2.value};`
        }
        function Reset(){
            bottom.style = ' background-color: black;'
            bottom.style = ' color: white;'
        }
    </script>
</div>
</body>
</html>